/* Example of Using Arrays */
#include <array>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <functional>
using namespace std;

template <typename T>
void PRINT_ELEMENTS(T const &vec)
{
	for (const auto &it : vec)
	{
		cout << it << " ";
	}
	cout << endl;
}

int main()
{
	// create array with 10 ints
	array<int, 10> a = { 11, 22, 33, 44 };
	PRINT_ELEMENTS(a);

	// modify last two elements
	a.back() = 9999;
	a[a.size() - 2] = 42;
	PRINT_ELEMENTS(a);

	//process sum of all elements
	cout << "sum: "
		<< accumulate(a.begin(), a.end(), 0)
		<< endl;

	// negate all elements
	transform(a.cbegin(), a.cend(),	// source
		a.begin(),					// destination
		negate<int>());				// operation
	PRINT_ELEMENTS(a);

	return 0;
}